<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">






  
  
    
      
    
    
      
    
  <script async src="//cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
  <link href="//cdn.jsdelivr.net/npm/pace-js@1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">








<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />


















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />


<link href="https://fonts.loli.net/css?family=EB+Garamond:400,400i,700,700i|Noto+Serif+SC:400,500,700&display=swap&subset=chinese-simplified" rel="stylesheet">




  

<link href="//cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo个人博客,NexT美化优化,哈林摇,Mac Panel特效,Leaf,若现,Java程序员,北京,旅行,摄像,Github Pages,搭建教程,demo,博客相册,文章排行榜,网站SEO" />




  


  <link rel="alternate" href="/atom.xml" title="chuang" type="application/atom+xml" />






<meta property="og:type" content="website">
<meta property="og:title" content="chuang">
<meta property="og:url" content="https://ruoxianer.github.io/index.html">
<meta property="og:site_name" content="chuang">
<meta property="article:author" content="若现">
<meta property="article:tag" content="若现">
<meta name="twitter:card" content="summary">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":true},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":true,"transition":{"post_block":"flipYIn","post_header":"perspectiveRightIn","post_body":"perspectiveLeftIn","coll_header":"swoopIn","sidebar":"shrinkIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://ruoxianer.github.io/"/>





<!-- 设置文章需要密码访问 -->
<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
</script>

  <title>chuang - 我真是个垃圾</title>
  









  
      <!-- 球型气泡标签云 -->
      <script type="text/javascript" src="/js/src/bubble.js"></script>
  

  
      <!-- haoyuePlayer 播放器，移动端大小适配-->
      <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
  

<meta name="generator" content="Hexo 4.2.0"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <!--fork me from github-->
    <a href="https://github.com/leafjame/hexo-theme-next5-leaf" target="_blank" rel="noopener" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">chuang</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">我真是个垃圾</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-life">
          <a href="/life/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-apple"></i> <br />
            
            生活
          </a>
        </li>
      
        
        <li class="menu-item menu-item-links">
          <a href="/links/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-link"></i> <br />
            
            友链
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <!--轮播图-->
  


<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>


<!--<script src="https://cdn.jsdelivr.net/npm/jquery@2.1.3/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap.min.js@3.3.5/bootstrap.min.js"></script>-->

<style type="text/css">

.glyphicon-chevron-left:before{
	/* content: "《" */
}
.glyphicon-chevron-right:before{
	/* content: "》" */
}

.right-siders{
   border-radius: 5px;
   /*margin-top: 5px;
   margin-bottom: 10px;*/
}

.my-carousel{
    /*height: 10%;*/
    margin-bottom: 12px;
}

.my-carousel:hover{
  margin-left: 5px;
  //padding: 5px 1px;
  border-radius: 5px;
  transform: scale(1.1);
  box-shadow: 10px 10px 15px 2px rgba(0,0,0,.12), 0 0 6px 0 rgba(104, 104, 105, 0.1);
}

@media (max-width: 767px){
	.rights{
		display: none;
	}
	.carousel{
		width: 100% !important;
		height: 100% !important;
	}
	.slide{
		width: 100% !important;
		height: 100% !important;
	}

	.carousel-control .glyphicon-chevron-left,
  .carousel-control .glyphicon-chevron-right,
  .carousel-control .icon-prev,
  .carousel-control .icon-next {
    width: 30px;
    height: 30px;
    margin-top: -10px;
    font-size: 30px;
  }
  .carousel-control .glyphicon-chevron-left,
  .carousel-control .icon-prev {
    margin-left: -10px;
  }
  .carousel-control .glyphicon-chevron-right,
  .carousel-control .icon-next {
   /* margin-right: -10px; */
  }

}

.carousel{
	width: 65%;
	height: 100%;
	position: relative;
}

.carousel-inner {
  position: relative;
  overflow: hidden;
  width: 100%;
}
.carousel-inner > .item {
  display: none;
  position: relative;
  -webkit-transition: 0.6s ease-in-out left;
  -o-transition: 0.6s ease-in-out left;
  transition: 0.6s ease-in-out left;
}
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
  line-height: 1;
}
@media all and (transform-3d), (-webkit-transform-3d) {
  .carousel-inner > .item {
    -webkit-transition: -webkit-transform 0.6s ease-in-out;
    -moz-transition: -moz-transform 0.6s ease-in-out;
    -o-transition: -o-transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    -moz-perspective: 1000px;
    perspective: 1000px;
  }
  .carousel-inner > .item.next,
  .carousel-inner > .item.active.right {
    -webkit-transform: translate3d(100%, 0, 0);
    transform: translate3d(100%, 0, 0);
    left: 0;
  }
  .carousel-inner > .item.prev,
  .carousel-inner > .item.active.left {
    -webkit-transform: translate3d(-100%, 0, 0);
    transform: translate3d(-100%, 0, 0);
    left: 0;
  }
  .carousel-inner > .item.next.left,
  .carousel-inner > .item.prev.right,
  .carousel-inner > .item.active {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    left: 0;
  }
}
.carousel-inner > .active,
.carousel-inner > .next,
.carousel-inner > .prev {
  display: block;
}
.carousel-inner > .active {
  left: 0;
}
.carousel-inner > .next,
.carousel-inner > .prev {
  position: absolute;
  top: 0;
  width: 100%;
}
.carousel-inner > .next {
  left: 100%;
}
.carousel-inner > .prev {
  left: -100%;
}
.carousel-inner > .next.left,
.carousel-inner > .prev.right {
  left: 0;
}
.carousel-inner > .active.left {
  left: -100%;
}
.carousel-inner > .active.right {
  left: 100%;
}
.carousel-control {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  /*width: 5%;*/
  opacity: 0.5;
  filter: alpha(opacity=50);
  font-size: 20px;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  background-color: rgba(0, 0, 0, 0);
}
.carousel-control.left {
  background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%);
  background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%);
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#80000000, endColorstr=#00000000, GradientType=1);
}
.carousel-control.right {
  left: auto;
  right: 0;
  background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%);
  background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%);
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00000000, endColorstr=#80000000, GradientType=1);
}
.carousel-control:hover,
.carousel-control:focus {
  outline: 0;
  color: #fff;
  text-decoration: none;
  opacity: 0.9;
  filter: alpha(opacity=90);
}
.carousel-control .icon-prev,
.carousel-control .icon-next,
.carousel-control .glyphicon-chevron-left,
.carousel-control .glyphicon-chevron-right {
  position: absolute;
  top: 50%;
  margin-top: -10px;
  z-index: 5;
  display: inline-block;
}
/*
.carousel-control .icon-prev,
.carousel-control .glyphicon-chevron-left {
  left: 50%;
  margin-left: -10px;
}
*/

.carousel-control .icon-prev,
.carousel-control .glyphicon-chevron-left {
  background: url('/images/icon-slides.png');
  background-position-y: -20px;
  left: 9px;
}

/*
.carousel-control .icon-next,
.carousel-control .glyphicon-chevron-right {
  right: 50%;
  margin-right: -10px;
}
*/

.carousel-control .icon-next,
.carousel-control .glyphicon-chevron-right {
  background: url('/images/icon-slides.png');
  background-position-x: -50px;
  background-position-y: -20px;
  right: 0px;
}

.carousel-control .icon-prev,
.carousel-control .icon-next {
  width: 20px;
  height: 20px;
  line-height: 1;
  font-family: serif;
}

.carousel-control .icon-prev:before {
  content: 2039;
}
.carousel-control .icon-next:before {
  content: 203a;
}

.carousel-indicators {
  opacity: 0.5;
  position: absolute;
  bottom: -15px;
  left: 50%;
  z-index: 15;
  width: 60%;
  margin-left: -30%;
  padding-left: 0;
  list-style: none;
  text-align: center;
}
.carousel-indicators li {
  display: inline-block;
  width: 30px;
  height: 3px;
  margin: 5px;
  text-indent: -999px;
  border: 1px solid #bbb;
  border-radius: 10px;
  cursor: pointer;
  background-color: rgba(0, 0, 0, .24);
}
.carousel-indicators .active {
  width: 30px;
  height: 3px;
  background-color: #fff;
}
.carousel-caption {
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: 20px;
  z-index: 10;
  padding-top: 20px;
  padding-bottom: 20px;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.carousel-caption .btn {
  text-shadow: none;
}
@media screen and (min-width: 768px) {
  .carousel-control .glyphicon-chevron-left,
  .carousel-control .glyphicon-chevron-right,
  .carousel-control .icon-prev,
  .carousel-control .icon-next {
    width: 30px;
    height: 30px;
    margin-top: -10px;
    font-size: 30px;
  }
  .carousel-control .glyphicon-chevron-left,
  .carousel-control .icon-prev {
    margin-left: -10px;
  }
  .carousel-control .glyphicon-chevron-right,
  .carousel-control .icon-next {
   /* margin-right: -10px; */
  }
  .carousel-caption {
    left: 20%;
    right: 20%;
    padding-bottom: 30px;
  }
  .carousel-indicators {
    bottom: -20px;
  }
}
</style>

<div width="100%" height="24%" style="border: 0px; overflow: hidden; border-radius: 10px; margin-bottom: 25px;" scrolling="no">

	<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="3500" style="float:left">

      <!-- 轮播（Carousel）指标 -->
      <ol class="carousel-indicators">
      
      
        <li data-target="#myCarousel" data-slide-to="0"></li>
        
      
        <li data-target="#myCarousel" data-slide-to="1"></li>
        
      
        <li data-target="#myCarousel" data-slide-to="2"></li>
        
      
        <li data-target="#myCarousel" data-slide-to="3"></li>
        
      
        <li data-target="#myCarousel" data-slide-to="4"></li>
        
      
      </ol>

      <!-- 轮播（Carousel）项目 -->
      <div class="carousel-inner" style="height: 24%; border-radius: 10px; width: 100%;">
       
       
          
          <a class="item active" href="/" target="_blank" style="height: 100%;">
            
            <img src="https://cdn.jsdelivr.net/gh/leafjame/cdn/img/carousel/knowledge.png" class="nofancybox"  style="width: 100%; height: 100%" >
          </a>
          
          
      
          
            <a class="item" href="/" target="_blank" style="height: 100%;">
              <img src="https://cdn.jsdelivr.net/gh/leafjame/cdn/img/carousel/mobile.png" class="nofancybox"  style="width: 100%; height: 100%;" >
            </a>
        
      
          
            <a class="item" href="https://mailchi.mp/e92415d27722/leaf" target="_blank" style="height: 100%;">
              <img src="https://cdn.jsdelivr.net/gh/leafjame/cdn/img/carousel/subscribe.png" class="nofancybox"  style="width: 100%; height: 100%;" >
            </a>
        
      
          
            <a class="item" href="/" target="_blank" style="height: 100%;">
              <img src="https://cdn.jsdelivr.net/gh/leafjame/cdn/img/carousel/share.png" class="nofancybox"  style="width: 100%; height: 100%;" >
            </a>
        
      
          
            <a class="item" href="/" target="_blank" style="height: 100%;">
              <img src="https://cdn.jsdelivr.net/gh/leafjame/cdn/img/carousel/photos.png" class="nofancybox"  style="width: 100%; height: 100%;" >
            </a>
        
      
      </div>

      <!-- 轮播（Carousel）导航 -->
      <a class="left carousel-control" data-target="#myCarousel" href="javascript:void(0);" role="button" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
      </a>
      <a class="right carousel-control" data-target="#myCarousel" href="javascript:void(0);" role="button" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
      </a>

	  </div>

	<div  class="rights" style="width: 30%; height: 24%; margin-right: 15px;margin-left: 0px;float: right;">

  	   <!-- 天气插件 -->
  	   <!-- 会有http的链接
       <iframe width="300px" scrolling="no" height="50px" frameborder="0" allowtransparency="true" src="https://i.tianqi.com/index.php?c=code&id=12&color=%23&bdc=%23&icon=1&py=beijing&num=2&site=12"></iframe>
       -->

       <!-- https://tianqi.2345.com/plugin/setting.htm -->
       <!-- <iframe allowtransparency="true" frameborder="0" width="290" height="75" scrolling="no" src="//tianqi.2345.com/plugin/widget/index.htm?s=2&z=2&t=0&v=0&d=2&bd=0&k=000000&f=&ltf=009944&htf=cc0000&q=1&e=1&a=1&c=54511&w=290&h=75&align=left"></iframe> -->
       <iframe allowtransparency="true" frameborder="0" width="300" height="55" scrolling="no" src="//tianqi.2345.com/plugin/widget/index.htm?s=2&z=3&t=1&v=2&d=1&bd=0&k=000000&f=&ltf=009944&htf=cc0000&q=1&e=1&a=1&c=54511&w=300&h=55&align=left"></iframe>

  	   <!-- 热门排行 -->
  	   <div class="my-carousel">
         <a href="https://www.liaofuzhan.com/top/" target="_blank">
            <img class="right-siders nofancybox" src="/images/hot.png" width="100%"/>
         </a>
  	   </div>

  	   <!-- 时光留影 -->
  	   <div class="my-carousel">
         <a href="https://www.liaofuzhan.com/photos/" target="_blank">
           <img class="right-siders nofancybox" src="/images/time.png"/>
         </a>
  	   </div>

  	  <!-- 推荐阅读 -->
  	  <div class="my-carousel">
        <a href="https://www.liaofuzhan.com/books/" target="_blank">
          <img class="right-siders nofancybox" src="/images/read.png"/>
        </a>
  	  </div>

      <!-- 订阅本站 -->
      <div class="my-carousel">
        <a href="https://mailchi.mp/e92415d27722/leaf" target="_blank">
          <img class="right-siders nofancybox" src="/images/subscribe.png"/>
        </a>
     </div>

   </div>

</div>




  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2022/04/11/python%E7%AE%80%E5%8D%95%E5%AE%9E%E7%8E%B0kmeans%E7%BB%98%E5%9B%BE%E6%98%BE%E7%A4%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2022/04/11/python%E7%AE%80%E5%8D%95%E5%AE%9E%E7%8E%B0kmeans%E7%BB%98%E5%9B%BE%E6%98%BE%E7%A4%BA/" itemprop="url">python简单实现kmeans绘图显示</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2022-04-11T19:07:39+08:00">
                2022-04-11
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  368
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>python简单实现kmeans绘图显示,大致思路是这样的,可以根据需要自己做出相应改进,完善绘图,导出聚类结果等</p>
<p>安装依赖包xlrd numpy  matplotlib </p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install numpy xlrd&#x3D;&#x3D;1.2.0 matplotlib</span><br></pre></td></tr></table></figure></div>

<p>示例数据 一个简单的excel表 两列数字</p>
<p><img src="/2022/04/11/python%E7%AE%80%E5%8D%95%E5%AE%9E%E7%8E%B0kmeans%E7%BB%98%E5%9B%BE%E6%98%BE%E7%A4%BA/data.png" alt></p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PYTHON"><figure class="iseeu highlight /python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> xlrd</span><br><span class="line"></span><br><span class="line"><span class="comment">#如果类别多的话 多设置几个颜色</span></span><br><span class="line">color_list = [<span class="string">'yellow'</span>,<span class="string">'red'</span>,<span class="string">'green'</span>,<span class="string">'purple'</span>,<span class="string">'black'</span>]</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">classify</span><span class="params">(data, centers)</span>:</span></span><br><span class="line">    <span class="string">"""</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    :param data:</span></span><br><span class="line"><span class="string">    :param centers:</span></span><br><span class="line"><span class="string">    :return: classes &#123;list&#125;,sumDis &#123;float&#125;</span></span><br><span class="line"><span class="string">    """</span></span><br><span class="line">    length = centers.shape[<span class="number">0</span>]</span><br><span class="line"></span><br><span class="line">    classes = [ [] <span class="keyword">for</span> i <span class="keyword">in</span> range(length) ]</span><br><span class="line"></span><br><span class="line">    sumDis = <span class="number">0</span></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(data.shape[<span class="number">0</span>]):</span><br><span class="line">        per_data = data[i]</span><br><span class="line">        diffMat = np.tile(per_data,(length,<span class="number">1</span>)) - centers</span><br><span class="line"></span><br><span class="line">        sqDiffMat = diffMat**<span class="number">2</span></span><br><span class="line">        sqDisMat = sqDiffMat.sum(axis=<span class="number">1</span>)</span><br><span class="line"></span><br><span class="line">        sortedIndex = sqDisMat.argsort()</span><br><span class="line"></span><br><span class="line">        classes[sortedIndex[<span class="number">0</span>]].append(list(per_data))</span><br><span class="line"></span><br><span class="line">        sumDis += sqDisMat[sortedIndex[<span class="number">0</span>]]</span><br><span class="line">    <span class="keyword">return</span> classes,sumDis</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">upCenters</span><span class="params">(classes)</span>:</span></span><br><span class="line">    centers = []</span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(len(classes)):</span><br><span class="line">        per_class = classes[i]<span class="comment">#list</span></span><br><span class="line">        per_class = np.array(per_class)</span><br><span class="line">        center = per_class.sum(axis=<span class="number">0</span>)/len(per_class)</span><br><span class="line">        centers.append(center)</span><br><span class="line">    <span class="keyword">return</span> np.array(centers)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">kmeans</span><span class="params">(data,centers,sumDis)</span>:</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">#聚类</span></span><br><span class="line">    classes,new_sumDis = classify(data,centers)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> sumDis == new_sumDis:</span><br><span class="line">        <span class="keyword">return</span></span><br><span class="line">    <span class="comment">#修改中心点</span></span><br><span class="line">    new_centers = upCenters(classes)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(len(new_centers)):</span><br><span class="line">        center = centers[i]</span><br><span class="line">        plt.scatter(center[<span class="number">0</span>],center[<span class="number">1</span>],s =<span class="number">16</span> *np.pi**<span class="number">2</span> ,marker=<span class="string">'x'</span>,c=color_list[i])</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(len(classes)):</span><br><span class="line">        per_class = classes[i]</span><br><span class="line">        <span class="keyword">for</span> c <span class="keyword">in</span> per_class:</span><br><span class="line">            plt.scatter(c[<span class="number">0</span>],c[<span class="number">1</span>],c = color_list[i])</span><br><span class="line"></span><br><span class="line">    plt.title(<span class="string">'sumDis%f'</span>%new_sumDis)</span><br><span class="line"></span><br><span class="line">    plt.show()</span><br><span class="line"></span><br><span class="line">    kmeans(data,new_centers,new_sumDis)</span><br><span class="line">    <span class="comment">#在聚类</span></span><br><span class="line">    <span class="comment">#再修改中心点</span></span><br><span class="line">    <span class="comment">#两次的总的距离一样就停止</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">getData</span><span class="params">(xlsx)</span>:</span></span><br><span class="line">    workbook = xlrd.open_workbook(xlsx)</span><br><span class="line">    worksheet = workbook.sheet_by_index(<span class="number">0</span>)</span><br><span class="line">    nrows,ncols = worksheet.nrows,worksheet.ncols</span><br><span class="line"></span><br><span class="line">    data = []</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(nrows):</span><br><span class="line">        temp = []<span class="comment">#[12,23]</span></span><br><span class="line">        <span class="keyword">for</span> j <span class="keyword">in</span> range(ncols):</span><br><span class="line">            temp.append(worksheet.cell_value(i,j))</span><br><span class="line">        data.append(temp)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> np.array(data)</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">    data = getData(<span class="string">'data.xlsx'</span>)</span><br><span class="line">    <span class="comment"># print(data)</span></span><br><span class="line">    centers = data[:<span class="number">5</span>]</span><br><span class="line">    kmeans(data,centers,<span class="number">0</span>)</span><br></pre></td></tr></table></figure></div>


          
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2021/04/24/%E8%AF%B7%E6%B1%82FeatureServer%E6%9C%8D%E5%8A%A1Geojson%EF%BC%8Ccanvas%E7%BB%98%E5%88%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/04/24/%E8%AF%B7%E6%B1%82FeatureServer%E6%9C%8D%E5%8A%A1Geojson%EF%BC%8Ccanvas%E7%BB%98%E5%88%B6/" itemprop="url">请求FeatureServer服务Geojson，canvas绘制</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2021-04-24T16:34:42+08:00">
                2021-04-24
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  952
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>请求FeatureServer服务Geojson，使用jcanvas绘制</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="HTML"><figure class="iseeu highlight /html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>test4<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        *&#123;</span><br><span class="line">            margin: 0;</span><br><span class="line">            padding: 0;</span><br><span class="line">        &#125;</span><br><span class="line">        html,body &#123;</span><br><span class="line">            width: 100%;</span><br><span class="line">            height: 100%;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="css">        <span class="selector-id">#can</span>,<span class="selector-id">#can-two</span>&#123;</span></span><br><span class="line">            border: 2px solid black;</span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">"https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js"</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">"https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">canvas</span> <span class="attr">id</span>=<span class="string">"can"</span> <span class="attr">width</span>=<span class="string">"800"</span> <span class="attr">height</span>=<span class="string">"600"</span>&gt;</span><span class="tag">&lt;/<span class="name">canvas</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">canvas</span> <span class="attr">id</span>=<span class="string">"can-two"</span> <span class="attr">width</span>=<span class="string">"800"</span> <span class="attr">height</span>=<span class="string">"600"</span>&gt;</span><span class="tag">&lt;/<span class="name">canvas</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"contorl"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"button"</span> <span class="attr">value</span>=<span class="string">"left"</span> <span class="attr">onclick</span>=<span class="string">"left()"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"button"</span> <span class="attr">value</span>=<span class="string">"zoomIn"</span> <span class="attr">onclick</span>=<span class="string">"zoomIn()"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"button"</span> <span class="attr">value</span>=<span class="string">"download"</span> <span class="attr">onclick</span>=<span class="string">"download()"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">drawPolygon</span><span class="params">(polygon,scalex)</span> </span>&#123;</span></span><br><span class="line"></span><br><span class="line">        ctx2.beginPath();</span><br><span class="line"></span><br><span class="line"><span class="actionscript">        <span class="comment">//[   [     [x,y],[x,y]          ]    ]</span></span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> points = polygon[<span class="number">0</span>];  <span class="comment">//[     [x,y],[x,y]          ]</span></span></span><br><span class="line"><span class="actionscript">        <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; points.length; i++) &#123;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> point = points[i];</span></span><br><span class="line"><span class="javascript">            <span class="keyword">var</span> x = <span class="built_in">Number</span>(point[<span class="number">0</span>])</span></span><br><span class="line"><span class="javascript">            <span class="keyword">var</span> y = <span class="built_in">Number</span>(point[<span class="number">1</span>])</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> l = (x - xmin) / scalex;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> t = <span class="number">600</span> - (y - ymin) / scalex;</span></span><br><span class="line"></span><br><span class="line">            if (i === 0) &#123;</span><br><span class="line">                ctx2.moveTo(l, t);</span><br><span class="line"><span class="actionscript">            &#125;<span class="keyword">else</span> &#123;</span></span><br><span class="line">                ctx2.lineTo(l,t)</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">        ctx2.fillStyle = <span class="string">"black"</span></span></span><br><span class="line"><span class="actionscript">        ctx2.strokeStyle = <span class="string">"red"</span></span></span><br><span class="line">        ctx2.closePath();</span><br><span class="line">        ctx2.stroke()</span><br><span class="line">        ctx2.fill()</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">drawGeojson</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line">        ctx2.clearRect(0, 0, 800, 600);</span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> featureUrl = <span class="string">`https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_Generalized/FeatureServer/0/query?geometry=&#123;"xmin":<span class="subst">$&#123;xmin&#125;</span>,"ymin":<span class="subst">$&#123;ymin&#125;</span>,"xmax":<span class="subst">$&#123;xmax&#125;</span>,"ymax":<span class="subst">$&#123;ymax&#125;</span>,"spatialReference":&#123;"wkid":4269,"latestWkid":4269&#125;&#125;&amp;inSR=4269&amp;outSR=4269&amp;resultType=tile&amp;returnExceededLimitFeatures=false&amp;f=geojson`</span>;</span></span><br><span class="line"><span class="javascript">        $.ajax(&#123;</span></span><br><span class="line">            url: featureUrl,</span><br><span class="line"><span class="actionscript">            method: <span class="string">'get'</span>,</span></span><br><span class="line"><span class="actionscript">            success: <span class="function"><span class="keyword">function</span> <span class="params">(data)</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">                <span class="keyword">var</span> object = <span class="built_in">JSON</span>.parse(data);</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">                <span class="comment">//o.features[0].geometry.coordinates[0][0]</span></span></span><br><span class="line"><span class="actionscript">                <span class="comment">//o.features[0].geometry.type</span></span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">                <span class="keyword">var</span> features = object.features;</span></span><br><span class="line"><span class="actionscript">                <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; features.length; i++) &#123;</span></span><br><span class="line"><span class="actionscript">                    <span class="keyword">var</span> feature = features[i];</span></span><br><span class="line"><span class="actionscript">                    <span class="keyword">var</span> geometry = feature.geometry;</span></span><br><span class="line"><span class="actionscript">                    <span class="keyword">var</span> type = geometry.type;</span></span><br><span class="line"><span class="actionscript">                    <span class="keyword">var</span> coordinates = geometry.coordinates;</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">                    <span class="keyword">var</span> scalex = (xmax - xmin) / <span class="number">800</span>;</span></span><br><span class="line"><span class="actionscript">                    <span class="keyword">if</span> (type === <span class="string">"Polygon"</span>) &#123;</span></span><br><span class="line"><span class="actionscript">                       <span class="comment">// coordinates [   [     [x,y],[x,y]          ]    ]</span></span></span><br><span class="line">                         drawPolygon(coordinates,scalex);</span><br><span class="line"></span><br><span class="line"><span class="actionscript">                    &#125;<span class="keyword">else</span> <span class="keyword">if</span>(type === <span class="string">"MultiPolygon"</span>) &#123;</span></span><br><span class="line"><span class="javascript">                        <span class="built_in">console</span>.log(coordinates);</span></span><br><span class="line"><span class="actionscript">                        <span class="keyword">for</span> (<span class="keyword">var</span> j = <span class="number">0</span>; j &lt; coordinates.length; j++) &#123;</span></span><br><span class="line"><span class="actionscript">                            <span class="keyword">var</span> polygon = coordinates[j];</span></span><br><span class="line">                            drawPolygon(polygon, scalex);</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">createDownload</span><span class="params">(fileName, content)</span> </span>&#123;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> blob = <span class="keyword">new</span> Blob([content]);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> link = <span class="built_in">document</span>.createElement(<span class="string">"a"</span>);</span></span><br><span class="line">        link.innerHTML = fileName;</span><br><span class="line">        link.download = fileName;</span><br><span class="line">        link.href = URL.createObjectURL(blob);</span><br><span class="line"><span class="javascript">        <span class="built_in">document</span>.getElementsByTagName(<span class="string">"body"</span>)[<span class="number">0</span>].appendChild(link);</span></span><br><span class="line">        link.click();</span><br><span class="line">        link.remove();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">download</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> featureUrl = <span class="string">`https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_Generalized/FeatureServer/0/query?geometry=&#123;"xmin":<span class="subst">$&#123;xmin&#125;</span>,"ymin":<span class="subst">$&#123;ymin&#125;</span>,"xmax":<span class="subst">$&#123;xmax&#125;</span>,"ymax":<span class="subst">$&#123;ymax&#125;</span>,"spatialReference":&#123;"wkid":4269,"latestWkid":4269&#125;&#125;&amp;inSR=4269&amp;outSR=4269&amp;resultType=tile&amp;returnExceededLimitFeatures=false&amp;f=geojson`</span>;</span></span><br><span class="line"><span class="javascript">        $.ajax(&#123;</span></span><br><span class="line">            url: featureUrl,</span><br><span class="line"><span class="actionscript">            method: <span class="string">'get'</span>,</span></span><br><span class="line"><span class="actionscript">            success: <span class="function"><span class="keyword">function</span> <span class="params">(data)</span> </span>&#123;</span></span><br><span class="line"><span class="actionscript">                <span class="comment">// console.log(data);</span></span></span><br><span class="line"><span class="actionscript">                createDownload(<span class="string">'usa.txt'</span>,data)</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">url</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">return</span> <span class="string">`https://sampleserver6.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer/export?bbox=<span class="subst">$&#123;xmin&#125;</span>%2C<span class="subst">$&#123;ymin&#125;</span>%2C<span class="subst">$&#123;xmax&#125;</span>%2C<span class="subst">$&#123;ymax&#125;</span>&amp;bboxSR=4269&amp;imageSR=4269&amp;size=800%2C600&amp;dpi=120&amp;format=png32&amp;transparent=true&amp;layers=show%3A0%2C1%2C2%2C3&amp;f=image`</span>;</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">draw</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"></span><br><span class="line">        drawGeojson();</span><br><span class="line"></span><br><span class="line"><span class="javascript">        $.cookie(<span class="string">'xmin'</span>, xmin, &#123;<span class="attr">expires</span>: <span class="number">7</span>, <span class="attr">path</span>: <span class="string">"/"</span>&#125;);</span></span><br><span class="line"><span class="javascript">        $.cookie(<span class="string">'xmax'</span>, xmax, &#123;<span class="attr">expires</span>: <span class="number">7</span>, <span class="attr">path</span>: <span class="string">"/"</span>&#125;);</span></span><br><span class="line"><span class="javascript">        $.cookie(<span class="string">'ymin'</span>, ymin, &#123;<span class="attr">expires</span>: <span class="number">7</span>, <span class="attr">path</span>: <span class="string">"/"</span>&#125;);</span></span><br><span class="line"><span class="javascript">        $.cookie(<span class="string">'ymax'</span>, ymax, &#123;<span class="attr">expires</span>: <span class="number">7</span>, <span class="attr">path</span>: <span class="string">"/"</span>&#125;);</span></span><br><span class="line">        img.src = url();</span><br><span class="line">        if (img.complete) &#123;</span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, 0, 0);</span><br><span class="line"><span class="actionscript">            <span class="keyword">return</span></span></span><br><span class="line">        &#125;</span><br><span class="line"><span class="actionscript">        img.onload = <span class="function"><span class="keyword">function</span> <span class="params">()</span> </span>&#123;</span></span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, 0, 0);</span><br><span class="line">        &#125;;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">left</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dx = xmax - xmin;</span></span><br><span class="line">        xmin += dx * 0.2;</span><br><span class="line">        xmax += dx * 0.2;</span><br><span class="line">        draw()</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="comment">//放大</span></span></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">zoomIn</span><span class="params">()</span></span>&#123;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dx = xmax - xmin;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dy = ymax - ymin;</span></span><br><span class="line">        xmin += dx / 4;</span><br><span class="line">        xmax -= dx / 4;</span><br><span class="line">        ymin += dy / 4;</span><br><span class="line">        ymax -= dy / 4;</span><br><span class="line">        draw();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="comment">//xmin":-111.54017591943592,"ymin":40.49209635279981,"xmax":-111.41984257464203,"ymax":40.58234636139523</span></span></span><br><span class="line"><span class="actionscript">    <span class="comment">// var xmin = -111.5342863648844, ymin = 40.49209635279982, xmax =-111.42573212919356, ymax = 40.58234636139524;</span></span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="comment">// var xmin = -111.54017591943592, ymin = 40.49209635279981, xmax =-111.41984257464203, ymax = 40.58234636139523;</span></span></span><br><span class="line"><span class="javascript">    <span class="keyword">var</span> xmin = <span class="built_in">Number</span>($.cookie(<span class="string">"xmin"</span>)), ymin = <span class="built_in">Number</span>($.cookie(<span class="string">"ymin"</span>)), xmax =<span class="built_in">Number</span>($.cookie(<span class="string">"xmax"</span>)), ymax = <span class="built_in">Number</span>($.cookie(<span class="string">"ymax"</span>));</span></span><br><span class="line"></span><br><span class="line">    if (!(xmin &amp;&amp; ymin &amp;&amp; xmax &amp;&amp; ymax)) &#123;</span><br><span class="line">        xmin = -111.54017591943592;</span><br><span class="line">        ymin = 40.49209635279981;</span><br><span class="line">        xmax =-111.41984257464203;</span><br><span class="line">        ymax = 40.58234636139523;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="javascript">    <span class="keyword">var</span> can = <span class="built_in">document</span>.getElementById(<span class="string">"can"</span>);</span></span><br><span class="line"><span class="javascript">    <span class="keyword">var</span> can2 = <span class="built_in">document</span>.getElementById(<span class="string">"can-two"</span>);</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> ctx = can.getContext(<span class="string">"2d"</span>);</span></span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> ctx2 = can2.getContext(<span class="string">"2d"</span>);</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> img = <span class="keyword">new</span> Image();</span></span><br><span class="line"></span><br><span class="line">    draw();</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    can.onmousedown = <span class="function"><span class="keyword">function</span> <span class="params">(event)</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> left = event.offsetX;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> top = event.offsetY;</span></span><br><span class="line"><span class="javascript">        <span class="built_in">console</span>.log(left, top);</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">        can.onmousemove = <span class="function"><span class="keyword">function</span><span class="params">(event)</span></span>&#123;</span></span><br><span class="line"><span class="javascript">            event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> left2 = event.offsetX;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> top2 = event.offsetY;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> moveleft = left2 - left;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> movetop = top2 - top;</span></span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, moveleft, movetop);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">        can.onmouseup = <span class="function"><span class="keyword">function</span> <span class="params">(event)</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">            event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> left1 = event.offsetX;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> top1 = event.offsetY;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> moveleft = left1 - left;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> movetop = top1 - top;</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> scalex = (xmax - xmin) / <span class="number">800</span>;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> scaley = (ymax - ymin) / <span class="number">600</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="javascript">            <span class="built_in">console</span>.log(scalex === scaley)</span></span><br><span class="line">            xmin -= moveleft * scalex;</span><br><span class="line">            xmax -= moveleft * scalex;</span><br><span class="line">            ymin += movetop * scaley;</span><br><span class="line">            ymax += movetop * scaley;</span><br><span class="line">            draw()</span><br><span class="line"></span><br><span class="line"><span class="actionscript">            can.onmouseup = <span class="literal">null</span>;</span></span><br><span class="line"><span class="actionscript">            can.onmousemove = <span class="literal">null</span>;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure></div>


          
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2021/04/17/FeatureServer%E8%AF%B7%E6%B1%82%E4%B8%8B%E8%BD%BDgeojson/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/04/17/FeatureServer%E8%AF%B7%E6%B1%82%E4%B8%8B%E8%BD%BDgeojson/" itemprop="url">FeatureServer请求下载geojson</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2021-04-17T14:04:10+08:00">
                2021-04-17
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  710
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>实现在地图内容发生变化时，请求并保存对应的矢量数据</p>
<p>保存当前地图范围，每次运行程序时可恢复上次的地图范围</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="HTML"><figure class="iseeu highlight /html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>test4<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        *&#123;</span><br><span class="line">            margin: 0;</span><br><span class="line">            padding: 0;</span><br><span class="line">        &#125;</span><br><span class="line">        html,body &#123;</span><br><span class="line">            width: 100%;</span><br><span class="line">            height: 100%;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="css">        <span class="selector-id">#can</span>&#123;</span></span><br><span class="line">            border: 2px solid black;</span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">"https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js"</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">"https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">canvas</span> <span class="attr">id</span>=<span class="string">"can"</span> <span class="attr">width</span>=<span class="string">"800"</span> <span class="attr">height</span>=<span class="string">"600"</span>&gt;</span><span class="tag">&lt;/<span class="name">canvas</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"contorl"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"button"</span> <span class="attr">value</span>=<span class="string">"left"</span> <span class="attr">onclick</span>=<span class="string">"left()"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"button"</span> <span class="attr">value</span>=<span class="string">"zoomIn"</span> <span class="attr">onclick</span>=<span class="string">"zoomIn()"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"button"</span> <span class="attr">value</span>=<span class="string">"download"</span> <span class="attr">onclick</span>=<span class="string">"download()"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">createDownload</span><span class="params">(fileName, content)</span> </span>&#123;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> blob = <span class="keyword">new</span> Blob([content]);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> link = <span class="built_in">document</span>.createElement(<span class="string">"a"</span>);</span></span><br><span class="line">        link.innerHTML = fileName;</span><br><span class="line">        link.download = fileName;</span><br><span class="line">        link.href = URL.createObjectURL(blob);</span><br><span class="line"><span class="javascript">        <span class="built_in">document</span>.getElementsByTagName(<span class="string">"body"</span>)[<span class="number">0</span>].appendChild(link);</span></span><br><span class="line">        link.click();</span><br><span class="line">        link.remove();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">download</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> featureUrl = <span class="string">`https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_Generalized/FeatureServer/0/query?geometry=&#123;"xmin":<span class="subst">$&#123;xmin&#125;</span>,"ymin":<span class="subst">$&#123;ymin&#125;</span>,"xmax":<span class="subst">$&#123;xmax&#125;</span>,"ymax":<span class="subst">$&#123;ymax&#125;</span>,"spatialReference":&#123;"wkid":4269,"latestWkid":4269&#125;&#125;&amp;inSR=4269&amp;outSR=4269&amp;resultType=tile&amp;returnExceededLimitFeatures=false&amp;f=geojson`</span>;</span></span><br><span class="line"><span class="javascript">        $.ajax(&#123;</span></span><br><span class="line">            url: featureUrl,</span><br><span class="line"><span class="actionscript">            method: <span class="string">'get'</span>,</span></span><br><span class="line"><span class="actionscript">            success: <span class="function"><span class="keyword">function</span> <span class="params">(data)</span> </span>&#123;</span></span><br><span class="line"><span class="actionscript">                <span class="comment">// console.log(data);</span></span></span><br><span class="line"><span class="actionscript">                createDownload(<span class="string">'usa.txt'</span>,data)</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">url</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">return</span> <span class="string">`https://sampleserver6.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer/export?bbox=<span class="subst">$&#123;xmin&#125;</span>%2C<span class="subst">$&#123;ymin&#125;</span>%2C<span class="subst">$&#123;xmax&#125;</span>%2C<span class="subst">$&#123;ymax&#125;</span>&amp;bboxSR=4269&amp;imageSR=4269&amp;size=800%2C600&amp;dpi=120&amp;format=png32&amp;transparent=true&amp;layers=show%3A0%2C1%2C2%2C3&amp;f=image`</span>;</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">draw</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        $.cookie(<span class="string">'xmin'</span>, xmin, &#123;<span class="attr">expires</span>: <span class="number">7</span>, <span class="attr">path</span>: <span class="string">"/"</span>&#125;);</span></span><br><span class="line"><span class="javascript">        $.cookie(<span class="string">'xmax'</span>, xmax, &#123;<span class="attr">expires</span>: <span class="number">7</span>, <span class="attr">path</span>: <span class="string">"/"</span>&#125;);</span></span><br><span class="line"><span class="javascript">        $.cookie(<span class="string">'ymin'</span>, ymin, &#123;<span class="attr">expires</span>: <span class="number">7</span>, <span class="attr">path</span>: <span class="string">"/"</span>&#125;);</span></span><br><span class="line"><span class="javascript">        $.cookie(<span class="string">'ymax'</span>, ymax, &#123;<span class="attr">expires</span>: <span class="number">7</span>, <span class="attr">path</span>: <span class="string">"/"</span>&#125;);</span></span><br><span class="line">        img.src = url();</span><br><span class="line">        if (img.complete) &#123;</span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, 0, 0);</span><br><span class="line"><span class="actionscript">            <span class="keyword">return</span></span></span><br><span class="line">        &#125;</span><br><span class="line"><span class="actionscript">        img.onload = <span class="function"><span class="keyword">function</span> <span class="params">()</span> </span>&#123;</span></span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, 0, 0);</span><br><span class="line">        &#125;;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">left</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dx = xmax - xmin;</span></span><br><span class="line">        xmin += dx * 0.2;</span><br><span class="line">        xmax += dx * 0.2;</span><br><span class="line">        draw()</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="comment">//放大</span></span></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">zoomIn</span><span class="params">()</span></span>&#123;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dx = xmax - xmin;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dy = ymax - ymin;</span></span><br><span class="line">        xmin += dx / 4;</span><br><span class="line">        xmax -= dx / 4;</span><br><span class="line">        ymin += dy / 4;</span><br><span class="line">        ymax -= dy / 4;</span><br><span class="line">        draw();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="comment">//xmin":-111.54017591943592,"ymin":40.49209635279981,"xmax":-111.41984257464203,"ymax":40.58234636139523</span></span></span><br><span class="line"><span class="actionscript">    <span class="comment">// var xmin = -111.5342863648844, ymin = 40.49209635279982, xmax =-111.42573212919356, ymax = 40.58234636139524;</span></span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="comment">// var xmin = -111.54017591943592, ymin = 40.49209635279981, xmax =-111.41984257464203, ymax = 40.58234636139523;</span></span></span><br><span class="line"><span class="javascript">    <span class="keyword">var</span> xmin = <span class="built_in">Number</span>($.cookie(<span class="string">"xmin"</span>)), ymin = <span class="built_in">Number</span>($.cookie(<span class="string">"ymin"</span>)), xmax =<span class="built_in">Number</span>($.cookie(<span class="string">"xmax"</span>)), ymax = <span class="built_in">Number</span>($.cookie(<span class="string">"ymax"</span>));</span></span><br><span class="line"></span><br><span class="line">    if (!(xmin &amp;&amp; ymin &amp;&amp; xmax &amp;&amp; ymax)) &#123;</span><br><span class="line">        xmin = -111.54017591943592;</span><br><span class="line">        ymin = 40.49209635279981;</span><br><span class="line">        xmax =-111.41984257464203;</span><br><span class="line">        ymax = 40.58234636139523;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="javascript">    <span class="keyword">var</span> can = <span class="built_in">document</span>.getElementById(<span class="string">"can"</span>);</span></span><br><span class="line">  </span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> ctx = can.getContext(<span class="string">"2d"</span>);</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> img = <span class="keyword">new</span> Image();</span></span><br><span class="line"></span><br><span class="line">    draw();</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    can.onmousedown = <span class="function"><span class="keyword">function</span> <span class="params">(event)</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> left = event.offsetX;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> top = event.offsetY;</span></span><br><span class="line"><span class="javascript">        <span class="built_in">console</span>.log(left, top);</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">        can.onmousemove = <span class="function"><span class="keyword">function</span><span class="params">(event)</span></span>&#123;</span></span><br><span class="line"><span class="javascript">            event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> left2 = event.offsetX;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> top2 = event.offsetY;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> moveleft = left2 - left;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> movetop = top2 - top;</span></span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, moveleft, movetop);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">        can.onmouseup = <span class="function"><span class="keyword">function</span> <span class="params">(event)</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">            event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> left1 = event.offsetX;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> top1 = event.offsetY;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> moveleft = left1 - left;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> movetop = top1 - top;</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> scalex = (xmax - xmin) / <span class="number">800</span>;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> scaley = (ymax - ymin) / <span class="number">600</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="javascript">            <span class="built_in">console</span>.log(scalex === scaley)</span></span><br><span class="line">            xmin -= moveleft * scalex;</span><br><span class="line">            xmax -= moveleft * scalex;</span><br><span class="line">            ymin += movetop * scaley;</span><br><span class="line">            ymax += movetop * scaley;</span><br><span class="line">            draw()</span><br><span class="line"></span><br><span class="line"><span class="actionscript">            can.onmouseup = <span class="literal">null</span>;</span></span><br><span class="line"><span class="actionscript">            can.onmousemove = <span class="literal">null</span>;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure></div>


          
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2021/04/16/MapServer%E8%AF%B7%E6%B1%82%E5%B9%B3%E7%A7%BB%E7%BC%A9%E6%94%BE%E6%8B%96%E6%8B%BD/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/04/16/MapServer%E8%AF%B7%E6%B1%82%E5%B9%B3%E7%A7%BB%E7%BC%A9%E6%94%BE%E6%8B%96%E6%8B%BD/" itemprop="url">MapServer请求平移缩放拖拽</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2021-04-16T13:30:02+08:00">
                2021-04-16
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  507
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>请求Arcgis server发布的Mapserver图片</p>
<p>请求地址：<a href="https://sampleserver6.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer" target="_blank" rel="noopener">https://sampleserver6.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer</a></p>
<p>实习目标</p>
<p>掌握利用Get方法请求地图图片</p>
<p>实习要求</p>
<p>基础要求：实现6个交互命令，地图上、下、左、右平移，地图放大、地图缩小</p>
<p>高阶要求：拖拽地图</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="HTML"><figure class="iseeu highlight /html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>test4<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        *&#123;</span><br><span class="line">            margin: 0;</span><br><span class="line">            padding: 0;</span><br><span class="line">        &#125;</span><br><span class="line">        html,body &#123;</span><br><span class="line">            width: 100%;</span><br><span class="line">            height: 100%;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="css">        <span class="selector-id">#can</span>&#123;</span></span><br><span class="line">            border: 2px solid black;</span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">canvas</span> <span class="attr">id</span>=<span class="string">"can"</span>&gt;</span><span class="tag">&lt;/<span class="name">canvas</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"contorl"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"button"</span> <span class="attr">value</span>=<span class="string">"left"</span> <span class="attr">onclick</span>=<span class="string">"left()"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"button"</span> <span class="attr">value</span>=<span class="string">"zoomIn"</span> <span class="attr">onclick</span>=<span class="string">"zoomIn()"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">url</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">return</span> <span class="string">`https://sampleserver6.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer/export?bbox=<span class="subst">$&#123;xmin&#125;</span>%2C<span class="subst">$&#123;ymin&#125;</span>%2C<span class="subst">$&#123;xmax&#125;</span>%2C<span class="subst">$&#123;ymax&#125;</span>&amp;bboxSR=4269&amp;imageSR=4269&amp;size=800%2C600&amp;dpi=120&amp;format=png32&amp;transparent=true&amp;layers=show%3A0%2C1%2C2%2C3&amp;f=image`</span>;</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">draw</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line">        img.src = url();</span><br><span class="line">        if (img.complete) &#123;</span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, 0, 0);</span><br><span class="line"><span class="actionscript">            <span class="keyword">return</span></span></span><br><span class="line">        &#125;</span><br><span class="line"><span class="actionscript">        img.onload = <span class="function"><span class="keyword">function</span> <span class="params">()</span> </span>&#123;</span></span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, 0, 0);</span><br><span class="line">        &#125;;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">left</span><span class="params">()</span> </span>&#123;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dx = xmax - xmin;</span></span><br><span class="line">        xmin += dx * 0.2;</span><br><span class="line">        xmax += dx * 0.2;</span><br><span class="line">        draw()</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="comment">//放大</span></span></span><br><span class="line"><span class="actionscript">    <span class="function"><span class="keyword">function</span> <span class="title">zoomIn</span><span class="params">()</span></span>&#123;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dx = xmax - xmin;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> dy = ymax - ymin;</span></span><br><span class="line">        xmin += dx / 4;</span><br><span class="line">        xmax -= dx / 4;</span><br><span class="line">        ymin += dy / 4;</span><br><span class="line">        ymax -= dy / 4;</span><br><span class="line">        draw();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="comment">//xmin":-111.54017591943592,"ymin":40.49209635279981,"xmax":-111.41984257464203,"ymax":40.58234636139523</span></span></span><br><span class="line"><span class="actionscript">    <span class="comment">// var xmin = -111.5342863648844, ymin = 40.49209635279982, xmax =-111.42573212919356, ymax = 40.58234636139524;</span></span></span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> xmin = <span class="number">-111.54017591943592</span>, ymin = <span class="number">40.49209635279981</span>, xmax =<span class="number">-111.41984257464203</span>, ymax = <span class="number">40.58234636139523</span>;</span></span><br><span class="line"><span class="javascript">    <span class="keyword">var</span> can = <span class="built_in">document</span>.getElementById(<span class="string">"can"</span>);</span></span><br><span class="line">    can.width = 800;</span><br><span class="line">    can.height = 600;</span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> ctx = can.getContext(<span class="string">"2d"</span>);</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> img = <span class="keyword">new</span> Image();</span></span><br><span class="line"></span><br><span class="line">    draw();</span><br><span class="line"></span><br><span class="line"><span class="actionscript">    can.onmousedown = <span class="function"><span class="keyword">function</span> <span class="params">(event)</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">        event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> left = event.offsetX;</span></span><br><span class="line"><span class="actionscript">        <span class="keyword">var</span> top = event.offsetY;</span></span><br><span class="line"><span class="javascript">        <span class="built_in">console</span>.log(left, top);</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">        can.onmousemove = <span class="function"><span class="keyword">function</span><span class="params">(event)</span></span>&#123;</span></span><br><span class="line"><span class="javascript">            event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> left2 = event.offsetX;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> top2 = event.offsetY;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> moveleft = left2 - left;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> movetop = top2 - top;</span></span><br><span class="line">            ctx.clearRect(0, 0, 800, 600);</span><br><span class="line">            ctx.drawImage(img, moveleft, movetop);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript">        can.onmouseup = <span class="function"><span class="keyword">function</span> <span class="params">(event)</span> </span>&#123;</span></span><br><span class="line"><span class="javascript">            event = event || <span class="built_in">window</span>.event;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> left1 = event.offsetX;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> top1 = event.offsetY;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> moveleft = left1 - left;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> movetop = top1 - top;</span></span><br><span class="line"></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> scalex = (xmax - xmin) / <span class="number">800</span>;</span></span><br><span class="line"><span class="actionscript">            <span class="keyword">var</span> scaley = (ymax - ymin) / <span class="number">600</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="javascript">            <span class="built_in">console</span>.log(scalex === scaley)</span></span><br><span class="line">            xmin -= moveleft * scalex;</span><br><span class="line">            xmax -= moveleft * scalex;</span><br><span class="line">            ymin += movetop * scaley;</span><br><span class="line">            ymax += movetop * scaley;</span><br><span class="line">            draw()</span><br><span class="line"></span><br><span class="line"><span class="actionscript">            can.onmouseup = <span class="literal">null</span>;</span></span><br><span class="line"><span class="actionscript">            can.onmousemove = <span class="literal">null</span>;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure></div>


          
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2021/01/25/c-%E5%AE%9E%E7%8E%B0KNN%E7%AE%97%E6%B3%95/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/01/25/c-%E5%AE%9E%E7%8E%B0KNN%E7%AE%97%E6%B3%95/" itemprop="url">c++实现KNN算法</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2021-01-25T09:46:42+08:00">
                2021-01-25
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  403
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <p>KNN，最近邻K个样本的类别决定位置样本的类别</p>
<p>使用c++简单实现，代码如下 </p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2021/01/25/c-%E5%AE%9E%E7%8E%B0KNN%E7%AE%97%E6%B3%95/" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2020/11/26/python%E5%AE%89%E8%A3%85Geopandas/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2020/11/26/python%E5%AE%89%E8%A3%85Geopandas/" itemprop="url">python安装Geopandas</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-11-26T17:53:17+08:00">
                2020-11-26
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  112
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h4 id="Python直接使用命令安装Geopandas出现错误"><a href="#Python直接使用命令安装Geopandas出现错误" class="headerlink" title="Python直接使用命令安装Geopandas出现错误"></a>Python直接使用命令安装Geopandas出现错误</h4><p>Geopandas依赖于GDAL，Fionan包，使用whl安装可以成功，<strong>亲测使用python3.7.3版本</strong></p>
<p>whl下载链接，记得选择对应版本</p>
<p><a href="https://www.lfd.uci.edu/~gohlke/pythonlibs/" target="_blank" rel="noopener">https://www.lfd.uci.edu/~gohlke/pythonlibs/</a></p>
<p><strong>按照下面三步依次安装即可成功</strong></p>
<ol>
<li><p>安装GDAL</p>
<img src="/2020/11/26/python%E5%AE%89%E8%A3%85Geopandas/gdal.png">

<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install GDAL-3.1.4-cp37-cp37m-win_amd64.whl</span><br></pre></td></tr></table></figure></div>



</li>
</ol>
<ol start="2">
<li><p>安装Fiona</p>
<img src="/2020/11/26/python%E5%AE%89%E8%A3%85Geopandas/FIona.png">

<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install Fiona-1.8.18-cp37-cp37m-win_amd64.whl</span><br></pre></td></tr></table></figure></div>



</li>
</ol>
<ol start="3">
<li><p>安装Geopandas</p>
<img src="/2020/11/26/python%E5%AE%89%E8%A3%85Geopandas/Geopandas.png">

<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install geopandas-0.6.2-py2.py3-none-any.whl</span><br></pre></td></tr></table></figure></div>



</li>
</ol>
<p>完成！！！</p>

          
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2020/11/11/windows%E5%91%BD%E4%BB%A4/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2020/11/11/windows%E5%91%BD%E4%BB%A4/" itemprop="url">windows命令</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-11-11T13:21:27+08:00">
                2020-11-11
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  332
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>​        </p>
<ol>
<li><p>如何查看ip地址</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ipconfig 			#查看ip地址基本信息</span><br><span class="line">ipconfig &#x2F;all	&#96;	#查看ip地址详细信息</span><br></pre></td></tr></table></figure></div>



</li>
</ol>
<ol start="2">
<li><p>测试网络连通性 </p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">ping 目标ip地址			#测试网络连通性，有去有回可以成功通信</span><br><span class="line">ping -t 目标ip地址		#一直ping</span><br><span class="line">ping -n 数字 目标ip地址  #修改ping包的数量</span><br><span class="line">ping -l 数字 目标ip地址  #修改ping包的大小</span><br><span class="line"></span><br><span class="line">#注：如果ping不通，可能对方不在线，或者对方开防火墙！</span><br></pre></td></tr></table></figure></div>



</li>
</ol>
<ol start="3">
<li><p>手动解析域名</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nslookup www.jd.com   	#手工解析域名的ip地址</span><br></pre></td></tr></table></figure></div>



</li>
</ol>
<p>文件操作</p>
<ol>
<li><p>创建文件</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">echo 内容 &gt; 文件名</span><br><span class="line">copy con 文件名 		#输入内容，ctrl+z结束输入</span><br><span class="line">fsutil file createnew 文件名 字节大小	#快速创建一个占多少空间的空文件</span><br></pre></td></tr></table></figure></div>



</li>
</ol>
<ol start="2">
<li><p>查看文件</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">type 文件名			#全部显示</span><br><span class="line">type 文件名|more 		#分页显示</span><br></pre></td></tr></table></figure></div>
</li>
<li><p>修改文件属性</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">attrib [] 文件名</span><br><span class="line">assoc .txt &#x3D; exefile</span><br></pre></td></tr></table></figure></div>



</li>
</ol>
<p>关机操作</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">shutdown -s -t 时间			#定时关机，单位为s</span><br><span class="line">shutdown -s -t 时间 -c 提示	   #定时关机，有提示，单位为s</span><br><span class="line">shutdown -s -f -t 时间		#定时强制关机</span><br><span class="line">shutdown -r -t 时间			#定时重启</span><br><span class="line">shutdown -a					 #取消一切定时操作</span><br><span class="line">shutdown -l					 #注销，同logoff</span><br></pre></td></tr></table></figure></div>

<p>针对xp或2003的蓝屏</p>
<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ntsd -c q -pn winlogon.exe</span><br></pre></td></tr></table></figure></div>

<div class="highlight-wrap"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">taskkill &#x2F;im explorer.exe &#x2F;f</span><br></pre></td></tr></table></figure></div>

<p>用户密码存放位置c:/windows/config/SAM</p>

          
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2020/10/28/NodeJS-Postgres%E9%94%99%E8%AF%AFgetaddrinfo-ENOTFOUND-NodeJS-Postgres-error-getaddrinfo-ENOTFOUND/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2020/10/28/NodeJS-Postgres%E9%94%99%E8%AF%AFgetaddrinfo-ENOTFOUND-NodeJS-Postgres-error-getaddrinfo-ENOTFOUND/" itemprop="url">NodeJS Postgres错误getaddrinfo ENOTFOUND(NodeJS Postgres error getaddrinfo ENOTFOUND)</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-10-28T13:22:34+08:00">
                2020-10-28
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  212
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="couldnot-connect-postgresql-Error-get-addrinfo-ENOTFOUND-postgres"><a href="#couldnot-connect-postgresql-Error-get-addrinfo-ENOTFOUND-postgres" class="headerlink" title="couldnot connect postgresql Error:get addrinfo ENOTFOUND postgres"></a>couldnot connect postgresql Error:get addrinfo ENOTFOUND postgres</h2><p>在使用Node连接Postgresql数据库时遇到了getaddrinfo ENOTFOUND的错误，提示couldnot connect postgresql Error:get addrinfo ENOTFOUND postgres错误，找不到主机地址。</p>
<img src="/2020/10/28/NodeJS-Postgres%E9%94%99%E8%AF%AFgetaddrinfo-ENOTFOUND-NodeJS-Postgres-error-getaddrinfo-ENOTFOUND/01.png">

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//引用pg模块</span></span><br><span class="line"><span class="keyword">var</span> pg = <span class="built_in">require</span>(<span class="string">'pg'</span>);</span><br><span class="line"><span class="comment">// var conString = "数据库类型://用户名:密码@服务器名称:端口号/数据库名称";</span></span><br><span class="line"><span class="keyword">var</span> conString = <span class="string">"postgres://postgres:123465?@localhost:5432/postgres"</span>;</span><br><span class="line"><span class="keyword">var</span> client = <span class="keyword">new</span> pg.Client(conString);</span><br></pre></td></tr></table></figure>

<p>检查几遍后，一直没发现问题</p>
<p>又尝试使用其他库，sequelize连接postgresql还是有问题</p>
<p>最后发现问题出现在密码上，密码里出现了 ？问号，应该是pg，sequelize没能正确识别出?是密码。</p>
<p>把密码更改了就好了，不要出现特殊字符</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2020/10/28/NodeJS-Postgres%E9%94%99%E8%AF%AFgetaddrinfo-ENOTFOUND-NodeJS-Postgres-error-getaddrinfo-ENOTFOUND/" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2020/05/06/c-%E5%AF%B9bmp%E7%81%B0%E5%BA%A6%E5%9B%BE%E5%83%8F%E8%BF%9B%E8%A1%8C%E5%83%8F%E7%B4%A0%E8%8C%83%E5%9B%B4%E6%8B%89%E4%BC%B8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2020/05/06/c-%E5%AF%B9bmp%E7%81%B0%E5%BA%A6%E5%9B%BE%E5%83%8F%E8%BF%9B%E8%A1%8C%E5%83%8F%E7%B4%A0%E8%8C%83%E5%9B%B4%E6%8B%89%E4%BC%B8/" itemprop="url">c++对bmp灰度图像进行像素范围拉伸</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-05-06T21:01:04+08:00">
                2020-05-06
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  595
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <p>使用c++对bmp灰度图像进行像素范围拉伸</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2020/05/06/c-%E5%AF%B9bmp%E7%81%B0%E5%BA%A6%E5%9B%BE%E5%83%8F%E8%BF%9B%E8%A1%8C%E5%83%8F%E7%B4%A0%E8%8C%83%E5%9B%B4%E6%8B%89%E4%BC%B8/" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://ruoxianer.github.io/2020/04/22/c-%E8%AF%BB%E5%8F%96bmp%E7%81%B0%E5%BA%A6%E5%9B%BE%E5%83%8F%EF%BC%8C%E8%BF%9B%E8%A1%8C%E7%9B%B4%E6%96%B9%E5%9B%BE%E7%BB%9F%E8%AE%A1%EF%BC%8C%E8%AE%A1%E7%AE%97%E6%9C%80%E5%80%BC%E3%80%81%E6%9C%9F%E6%9C%9B%E7%AD%89/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="若现">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/beichen.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chuang">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2020/04/22/c-%E8%AF%BB%E5%8F%96bmp%E7%81%B0%E5%BA%A6%E5%9B%BE%E5%83%8F%EF%BC%8C%E8%BF%9B%E8%A1%8C%E7%9B%B4%E6%96%B9%E5%9B%BE%E7%BB%9F%E8%AE%A1%EF%BC%8C%E8%AE%A1%E7%AE%97%E6%9C%80%E5%80%BC%E3%80%81%E6%9C%9F%E6%9C%9B%E7%AD%89/" itemprop="url">c++读取bmp灰度图像，进行直方图统计，计算最值、期望等</a></h2>
        

        <div class="post-meta">
          <span class="post-time">

             

             

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-04-22T22:45:54+08:00">
                2020-04-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          <!--
          
          -->

          
            <span class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                <span title="字数">
                  670
                </span>
              

              

              
            </span>
          

          <!-- 隐藏文章内标题下，内容描述
          
          -->

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <p>良好的开端是成功的一半（Well begun is half done）</p>
<p>第一次用c++读取图片时，难为坏我玛卡巴卡了，分享一下代码，愿你有一个美好的学习体验</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2020/04/22/c-%E8%AF%BB%E5%8F%96bmp%E7%81%B0%E5%BA%A6%E5%9B%BE%E5%83%8F%EF%BC%8C%E8%BF%9B%E8%A1%8C%E7%9B%B4%E6%96%B9%E5%9B%BE%E7%BB%9F%E8%AE%A1%EF%BC%8C%E8%AE%A1%E7%AE%97%E6%9C%80%E5%80%BC%E3%80%81%E6%9C%9F%E6%9C%9B%E7%AD%89/" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

      <!-- 相关文章推荐 -->
     

    
    
    

    <div>
          
    </div>

    

    <div>
      
    </div>

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="extend next" rel="next" href="/page/2/">&lt;i class&#x3D;&quot;fa fa-angle-right&quot;&gt;&lt;&#x2F;i&gt;</a>
  </nav>



          </div>
          


          



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
      <div id="sidebar-dimmer"></div>
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <a href="/">
              <img class="site-author-image" itemprop="image"
                src="/images/beichen.png"
                alt="若现" />
              </a>
            
              <p class="site-author-name" itemprop="name">若现</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">11</span>
                  <span class="site-state-item-name">文章</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
              <!-- 为Hexo Next主题添加哈林摇特效  -->
              <a title="收藏到书签，偶尔High一下^_^" rel="alternate" class="mw-harlem_shake_slow wobble shake" href="javascript:void(0)" onclick="javascript:(function go() {function c() {var e = document.createElement('link');e.setAttribute('type', 'text/css');e.setAttribute('rel', 'stylesheet');e.setAttribute('href', f);e.setAttribute('class', l);document.body.appendChild(e)}function h(){var e = document.getElementsByClassName(l);for(var t = 0; t< e.length; t++){document.body.removeChild(e[t])}}function p(){var e = document.createElement('div');e.setAttribute('class', a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s = d(i);return s.height>e &amp;&amp;s.height<n &amp;&amp; s.width>t &amp;&amp;s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=document.documentElement;if(!!window.innerWidth){return window.innerHeight}else if(e &amp;&amp; !isNaN(e.clientHeight)){return e.clientHeight}return 0}function y(){if(window.pageYOffset){return window.pageYOffset}return Math.max(document.documentElement.scrollTop,document.body.scrollTop)}function E(e){var t=m(e);return t>=w &amp;&amp; t<=b+w}var songs=['https://www.liaofuzhan.com/music/无尽光芒.mp3'];function S(){var e=document.getElementById('audio_element_id');if(e!=null){var index=parseInt(e.getAttribute('curSongIndex'));if(index>songs.length-2){index=0;}else{index++;}e.setAttribute('curSongIndex',index);N();}e.src=i;e.play()}function x(e){e.className+=' '+s+' '+o}function T(e){e.className+=' '+s+' '+u[Math.floor(Math.random()*u.length)]}function N(){var e=document.getElementsByClassName(s);var t=new RegExp('\\b'+s+'\\b');for(var n=0;n<e.length;){e[n].className=e[n].className.replace(t,'')}}function initAudioEle(){var e=document.getElementById('audio_element_id');if(e===null){e=document.createElement('audio');e.setAttribute('class',l);e.setAttribute('curSongIndex',0);e.id='audio_element_id';e.loop=false;e.bgcolor=0;e.addEventListener('canplay',function(){setTimeout(function(){x(k)},500);setTimeout(function(){N();p();for(var e=0;e<O.length;e++){T(O[e])}},15500)},true);e.addEventListener('ended',function(){N();h();go();},true);e.innerHTML='<p>If you are reading this,it is because your browser does not support the audio element. We recommend that you get a new browser.</p><p>';document.body.appendChild(e);}}initAudioEle();var e=30;var t=30;var n=350;var r=350;var curSongIndex=parseInt(document.getElementById('audio_element_id').getAttribute('curSongIndex'));var i=songs[curSongIndex];var s='mw-harlem_shake_me';var o='im_first';var u=['im_drunk','im_baked','im_trippin','im_blown'];var a='mw-strobe_light';var f='https://s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css';var l='mw_added_css';var b=g();var w=y();var C=document.getElementsByTagName('*');var k=null;for(var L=0;L<C.length;L++){var A=C[L];if(v(A)){if(E(A)){k=A;break}}}if(A===null){console.warn('Could not find a node of the right size. Please try a different page.');return}c();S();var O=[];for(var L=0;L<C.length;L++){var A=C[L];if(v(A)){O.push(A)}}})()"><i class="fa fa-music"></i> High~</a>

            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a rel="external nofollow" href="https://github.com/ruoxianer" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i></a>
                  </span>
                
            </div>
          

            <!--
            <div id="music163player">
                <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1336790004&auto=1&height=66"></iframe>
            </div>
            -->

          
          

          
          

          <!--近期文章版块 began-->
          
              <div class="links-of-blogroll motion-element links-of-blogroll-block">
                <div class="links-of-blogroll-title">
                  <i class="fa fa-history fa-" aria-hidden="true"></i>
                  近期文章
                </div>
                <ul class="links-of-blogroll-list">
                  
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/2022/04/11/python%E7%AE%80%E5%8D%95%E5%AE%9E%E7%8E%B0kmeans%E7%BB%98%E5%9B%BE%E6%98%BE%E7%A4%BA/" title="python简单实现kmeans绘图显示" target="_blank">python简单实现kmeans绘图显示</a>
                    </li>
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/2021/04/24/%E8%AF%B7%E6%B1%82FeatureServer%E6%9C%8D%E5%8A%A1Geojson%EF%BC%8Ccanvas%E7%BB%98%E5%88%B6/" title="请求FeatureServer服务Geojson，canvas绘制" target="_blank">请求FeatureServer服务Geojson，canvas绘制</a>
                    </li>
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/2021/04/17/FeatureServer%E8%AF%B7%E6%B1%82%E4%B8%8B%E8%BD%BDgeojson/" title="FeatureServer请求下载geojson" target="_blank">FeatureServer请求下载geojson</a>
                    </li>
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/2021/04/16/MapServer%E8%AF%B7%E6%B1%82%E5%B9%B3%E7%A7%BB%E7%BC%A9%E6%94%BE%E6%8B%96%E6%8B%BD/" title="MapServer请求平移缩放拖拽" target="_blank">MapServer请求平移缩放拖拽</a>
                    </li>
                  
                    <li class='my-links-of-blogroll-li'>
                      <a href="/2021/01/25/c-%E5%AE%9E%E7%8E%B0KNN%E7%AE%97%E6%B3%95/" title="c++实现KNN算法" target="_blank">c++实现KNN算法</a>
                    </li>
                  
                </ul>
              </div>
          
          <!--近期文章版块 end-->

          
              <!-- canvas粒子时钟 -->
              <!-- canvas粒子时钟 https://www.cnblogs.com/xiaohuochai/p/6368039.html
  https://www.html5tricks.com/html5-canvas-dance-time.html
 -->
<div id="">
  <canvas id="canvas" style="width:60%;">
</div>
<script async>
(function(){
  var WINDOW_WIDTH = 820;
  		var WINDOW_HEIGHT = 250;
  		var RADIUS = 7; //球半径
  		var NUMBER_GAP = 10; //数字之间的间隙
  		var u=0.65; //碰撞能量损耗系数
  		var context; //Canvas绘制上下文
  		var balls = []; //存储彩色的小球
  		const colors = ["#33B5E5","#0099CC","#AA66CC","#9933CC","#99CC00","#669900","#FFBB33","#FF8800","#FF4444","#CC0000"]; //彩色小球的颜色
  		var currentNums = []; //屏幕显示的8个字符
  		var digit =
                  [
                      [
                          [0,0,1,1,1,0,0],
                          [0,1,1,0,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,0,1,1,0],
                          [0,0,1,1,1,0,0]
                      ],//0
                      [
                          [0,0,0,1,1,0,0],
                          [0,1,1,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [1,1,1,1,1,1,1]
                      ],//1
                      [
                          [0,1,1,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,0,0],
                          [0,0,1,1,0,0,0],
                          [0,1,1,0,0,0,0],
                          [1,1,0,0,0,0,0],
                          [1,1,0,0,0,1,1],
                          [1,1,1,1,1,1,1]
                      ],//2
                      [
                          [1,1,1,1,1,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,0,0],
                          [0,0,1,1,1,0,0],
                          [0,0,0,0,1,1,0],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0]
                      ],//3
                      [
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,1,0],
                          [0,0,1,1,1,1,0],
                          [0,1,1,0,1,1,0],
                          [1,1,0,0,1,1,0],
                          [1,1,1,1,1,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,0,1,1,0],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,1,1]
                      ],//4
                      [
                          [1,1,1,1,1,1,1],
                          [1,1,0,0,0,0,0],
                          [1,1,0,0,0,0,0],
                          [1,1,1,1,1,1,0],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0]
                      ],//5
                      [
                          [0,0,0,0,1,1,0],
                          [0,0,1,1,0,0,0],
                          [0,1,1,0,0,0,0],
                          [1,1,0,0,0,0,0],
                          [1,1,0,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0]
                      ],//6
                      [
                          [1,1,1,1,1,1,1],
                          [1,1,0,0,0,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,0,0],
                          [0,0,0,1,1,0,0],
                          [0,0,1,1,0,0,0],
                          [0,0,1,1,0,0,0],
                          [0,0,1,1,0,0,0],
                          [0,0,1,1,0,0,0]
                      ],//7
                      [
                          [0,1,1,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,1,1,0]
                      ],//8
                      [
                          [0,1,1,1,1,1,0],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [1,1,0,0,0,1,1],
                          [0,1,1,1,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,0,1,1],
                          [0,0,0,0,1,1,0],
                          [0,0,0,1,1,0,0],
                          [0,1,1,0,0,0,0]
                      ],//9
                      [
                          [0,0,0,0],
                          [0,0,0,0],
                          [0,1,1,0],
                          [0,1,1,0],
                          [0,0,0,0],
                          [0,0,0,0],
                          [0,1,1,0],
                          [0,1,1,0],
                          [0,0,0,0],
                          [0,0,0,0]
                      ]//:
                  ];

  		function drawDatetime(cxt){
  			var nums = [];

  			context.fillStyle="#005eac"
  			var date = new Date();
  			var offsetX = 70, offsetY = 30;
  			var hours = date.getHours();
  			var num1 = Math.floor(hours/10);
  			var num2 = hours%10;
  			nums.push({num: num1});
  			nums.push({num: num2});
  			nums.push({num: 10}); //冒号
  			var minutes = date.getMinutes();
  			var num1 = Math.floor(minutes/10);
  			var num2 = minutes%10;
  			nums.push({num: num1});
  			nums.push({num: num2});
  			nums.push({num: 10}); //冒号
  			var seconds = date.getSeconds();
  			var num1 = Math.floor(seconds/10);
  			var num2 = seconds%10;
  			nums.push({num: num1});
  			nums.push({num: num2});

  			for(var x = 0;x<nums.length;x++){
  				nums[x].offsetX = offsetX;
  				offsetX = drawSingleNumber(offsetX,offsetY, nums[x].num,cxt);
  				//两个数字连一块，应该间隔一些距离
  				if(x<nums.length-1){
  					if((nums[x].num!=10) &&(nums[x+1].num!=10)){
  						offsetX+=NUMBER_GAP;
  					}
  				}
  			}

  			//说明这是初始化
  			if(currentNums.length ==0){
  				currentNums = nums;
  			}else{
  				//进行比较
  				for(var index = 0;index<currentNums.length;index++){
  					if(currentNums[index].num!=nums[index].num){
  						//不一样时，添加彩色小球
  						addBalls(nums[index]);
  						currentNums[index].num=nums[index].num;
  					}
  				}
  			}
  			renderBalls(cxt);
  			updateBalls();

  			return date;
  		}

  		function addBalls (item) {
  			var num = item.num;
  			var numMatrix = digit[num];
  			for(var y = 0;y<numMatrix.length;y++){
  				for(var x = 0;x<numMatrix[y].length;x++){
  					if(numMatrix[y][x]==1){
  						var ball={
  							offsetX:item.offsetX+RADIUS+RADIUS*2*x,
  							offsetY:30+RADIUS+RADIUS*2*y,
  							color:colors[Math.floor(Math.random()*colors.length)],
  							g:1.5+Math.random(),
  							vx:Math.pow(-1, Math.ceil(Math.random()*10))*4+Math.random(),
  							vy:-5
  						}
  						balls.push(ball);
  					}
  				}
  			}
  		}

  		function renderBalls(cxt){
  			for(var index = 0;index<balls.length;index++){
  				cxt.beginPath();
  				cxt.fillStyle=balls[index].color;
  				cxt.arc(balls[index].offsetX, balls[index].offsetY, RADIUS, 0, 2*Math.PI);
  				cxt.fill();
  			}
  		}

  		function updateBalls () {
  			var i =0;
  			for(var index = 0;index<balls.length;index++){
  				var ball = balls[index];
  				ball.offsetX += ball.vx;
  				ball.offsetY += ball.vy;
  				ball.vy+=ball.g;
  				if(ball.offsetY > (WINDOW_HEIGHT-RADIUS)){
  					ball.offsetY= WINDOW_HEIGHT-RADIUS;
  					ball.vy=-ball.vy*u;
  				}
  				if(ball.offsetX>RADIUS&&ball.offsetX<(WINDOW_WIDTH-RADIUS)){

  					balls[i]=balls[index];
  					i++;
  				}
  			}
  			//去除出边界的球
  			for(;i<balls.length;i++){
  				balls.pop();
  			}
  		}
  		function drawSingleNumber(offsetX, offsetY, num, cxt){
  			var numMatrix = digit[num];
  			for(var y = 0;y<numMatrix.length;y++){
  				for(var x = 0;x<numMatrix[y].length;x++){
  					if(numMatrix[y][x]==1){
  						cxt.beginPath();
  						cxt.arc(offsetX+RADIUS+RADIUS*2*x,offsetY+RADIUS+RADIUS*2*y,RADIUS,0,2*Math.PI);
  						cxt.fill();
  					}
  				}
  			}
  			cxt.beginPath();
  			offsetX += numMatrix[0].length*RADIUS*2;
  			return offsetX;
  		}

  		var canvas = document.getElementById("canvas");
  		canvas.width=WINDOW_WIDTH;
  		canvas.height=WINDOW_HEIGHT;
  		context = canvas.getContext("2d");

  		//记录当前绘制的时刻
  		var currentDate = new Date();

  		setInterval(function(){
  			//清空整个Canvas，重新绘制内容
  			context.clearRect(0, 0, context.canvas.width, context.canvas.height);
  			drawDatetime(context);
  		}, 50)
})();
</script>

          
          

        </div>
      </section>

      

      

      

      <!-- 标签云 -->
      <!--
      
      <script type="text/javascript" charset="utf-8" src="/js/tagcloud.js"></script>
      <script type="text/javascript" charset="utf-8" src="/js/tagcanvas.js"></script>
      <div class="widget-wrap">
      <h3 class="widget-title">Tag Cloud</h3>
      <div id="myCanvasContainer" class="widget tagcloud">
          <canvas width="250" height="250" id="resCanvas" style="width=100%">
              <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/" rel="tag">-c++</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/" rel="tag">c++</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/node/" rel="tag">node</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/postgresql/" rel="tag">postgresql</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86/" rel="tag">图像处理</a><span class="tag-list-count">2</span></li></ul>
          </canvas>
      </div>
      </div>
      
      -->
      <!-- 标签云 -->

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; 2019 &mdash; <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
       <i class="fa fa-heartbeat"></i>
  </span>
  <!--
    <span class="author" itemprop="copyrightHolder"> &nbsp;若现</span>
  -->
  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
    <span title="Site words total count">4.9k</span>
  
</div>












  <div class="subscribe-box">
    <div class="subscribe-menu">
      <div class="subscribe-hover">
        <div class="subscribe-description">微信扫一扫，关注公众号</div>
      </div>
    </div>
  </div>


        
<div class="busuanzi-count">
  <!--
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
  -->
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

   

  
  
    
      <span class="site-uv">
        
        我的第 <span class="busuanzi-value" id="busuanzi_value_site_uv"></span> 位朋友，
      </span>
    

    
      <span class="site-pv">
        历经 <span class="busuanzi-value" id="busuanzi_value_site_pv"></span> 次回眸才与你相遇
        <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      </span>
    
  

</div>








        
      </div>
    </footer>

    
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  










  



  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/npm/jquery@2.1.3/dist/jquery.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fastclick/1.0.6/fastclick.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazyload/1.9.3/jquery.lazyload.min.js"></script>
  

  
  
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/velocity-animate@1.2.1/velocity.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/npm/velocity-animate@1.2.1/velocity.ui.min.js"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script id="ribbon" type="text/javascript" size="60" alpha="0.1"  zIndex="-1" src="/lib/canvas-ribbon/canvas-ribbon.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  















  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "./public/search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  

  

  


  <!-- Tidio 在线联系功能、鼠标点击特效、页面反馈...-->
  


  
    <canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;" ></canvas>
    <script async src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script>
    <script async src="/js/cursor/explosion.min.js"></script>
  










  <script src="/js/src/activate-power-mode.min.js"></script>
  <script>
    POWERMODE.colorful = true;
    POWERMODE.shake = false;
    document.body.addEventListener('input', POWERMODE);
  </script>






  <script async language="javascript">

    var div = document.createElement("div");
    //插入到自定义的theme-info或者copyright之后
    var copyright = document.querySelector(".theme-info2") || document.querySelector(".copyright");

    function show_run_time(){
        window.setTimeout("show_run_time()", 1000);
      // BirthDay=new Date("08/07/2019 20:00:00");
        BirthDay=new Date("04/07/2020 20:00:00");
        today=new Date();
        timeold=(today.getTime()-BirthDay.getTime());
        sectimeold=timeold/1000
        secondsold=Math.floor(sectimeold);
        msPerDay=24*60*60*1000
        e_daysold=timeold/msPerDay
        daysold=Math.floor(e_daysold);
        e_hrsold=(e_daysold-daysold)*24;
        hrsold=setzero(Math.floor(e_hrsold));
        e_minsold=(e_hrsold-hrsold)*60;
        minsold=setzero(Math.floor((e_hrsold-hrsold)*60));
        seconds=setzero(Math.floor((e_minsold-minsold)*60));

        // 使用zh-Hans.yml的文字替换
        div.innerHTML = "我已在此等候你 " + "<span style='color: #1890ff'> " + daysold + " </span> 天 <span style='color: #1890ff'>" + hrsold + " </span>时 <span style='color: #1890ff'>" + minsold + " </span>分 <span style='color: #1890ff'>" + seconds + " </span>秒 ";

        document.querySelector(".footer-inner").insertBefore(div, copyright.nextSibling);

    }
    function setzero(i){
        if (i<10)
        {i="0" + i};
        return i;
    }

    show_run_time();

  </script>




<!-- 旋转魔方 -->

   
      
<style>
    .cube_container {
      width: 50px;
      height: 60px;
      margin: 0 auto;
      position: fixed;
      z-index: 999;
      -webkit-perspective: 1000px;
              perspective: 1000px;
      right: 0px;
      bottom: 0px;
      -webkit-transform: translate(-50%, -50%);
              transform: translate(-50%, -50%);
    }

    .cube {
      /*
      width: 100%;
      height: 100%;
      */
      width: 0%; /* 大角度旋转 */
      position: absolute;
      -webkit-transform-style: preserve-3d;
      transform-style: preserve-3d;
      -webkit-transform: rotateX(-15deg) rotateY(-20deg) translateZ(-100px);
      transform: rotateX(-15deg) rotateY(-20deg) translateZ(-100px);
      -webkit-transform-origin: center center -100px;
      transform-origin: center center -100px;
      -webkit-animation: around 5s cubic-bezier(0.94, -0.6, 0.45, 1.31) infinite;
      animation: around 5s cubic-bezier(0.94, -0.6, 0.45, 1.31) infinite;
    }
    .cube div {
      width: 50px;
      height: 50px;
      display: block;
      margin: 0;
      position: absolute;
    }
    .cube div a {
      color: white;
      font-size: 12px;
      text-decoration: none;
      text-align: center;
      position: fixed;
      top: 50%;
      left: 45%;
      -webkit-transform: translate(-50%, -50%);
              transform: translate(-50%, -50%);
    }
    .cube .front {
      -webkit-transform: rotateY(0deg) translateZ(25px);
              transform: rotateY(0deg) translateZ(25px);
      background-color: rgba(0, 191, 255, 0.7);
      border: 1px solid rgba(0, 191, 255, 0.7);
    }
    .cube .back {
      -webkit-transform: rotateX(180deg) translateZ(25px);
              transform: rotateX(180deg) translateZ(25px);
      background-color: rgba(124, 252, 0, 0.7);
      border: 1px solid rgba(124, 252, 0, 0.7);
    }
    .cube .left {
      -webkit-transform: rotateY(-90deg) translateZ(25px);
              transform: rotateY(-90deg) translateZ(25px);
      background-color: rgba(255, 215, 0, 0.7);
      border: 1px solid rgba(255, 215, 0, 0.7);
    }
    .cube .right {
      -webkit-transform: rotateY(90deg) translateZ(25px);
              transform: rotateY(90deg) translateZ(25px);
      background-color: rgba(255, 69, 0, 0.7);
      border: 1px solid rgba(255, 69, 0, 0.7);
    }
    .cube .top {
      -webkit-transform: rotateX(90deg) translateZ(25px);
              transform: rotateX(90deg) translateZ(25px);
      background-color: rgba(255, 0, 157, 0.7);
      border: 1px solid rgba(255, 0, 157, 0.7);
    }
    .cube .bottom {
      -webkit-transform: rotateX(-90deg) translateZ(25px);
              transform: rotateX(-90deg) translateZ(25px);
      background-color: rgba(184, 111, 220, 0.7);
      border: 1px solid rgba(184, 111, 220, 0.7);
    }

     @-webkit-keyframes around {
      100% {
        -webkit-transform: rotateX(-15deg) rotateY(-380deg) translateZ(-100px);
                transform: rotateX(-15deg) rotateY(-380deg) translateZ(-100px);
      }
    }

    @keyframes around {
      100% {
        -webkit-transform: rotateX(-15deg) rotateY(-380deg) translateZ(-100px);
        transform: rotateX(-15deg) rotateY(-380deg) translateZ(-100px);
      }
    }
</style>

<div class="cube_container">
	  <div class="cube">
	    <div class="front"><a onclick="back2top()" rel="nofollow"> 欢迎光临 </a></div>
	    <div class="back"><a onclick="back2top()" rel="nofollow"> ❤️ </a></div>
	    <div class="right"><a onclick="back2top()" rel="nofollow"> 北宸小站 </a></div>
	    <div class="left"><a onclick="back2top()" role="button" rel="nofollow"> 请多关照 </a></div>
	    <div class="top"><a href="https://github.com/leafjame/hexo-theme-next5-leaf" target="_blank" rel="nofollow"> ❤️ </a></div>
	    <div class="bottom"><a href="https://github.com/leafjame/hexo-theme-next5-leaf" target="_blank" rel="nofollow"> ❤️ </a></div>
	  </div>
</div>

<script>

  function back2top(){
    $('html, body').animate({scrollTop: 0}, 500);
  }

</script>

   


<!-- Console 输出第三方个性化字体 -->


  <!-- Console 输出自定义字体 -->
  


  <!-- 看板娘 -->
  
      <script async src="/live2d-widget/autoload.js"></script>
  

  

  

  <!-- 代码块复制功能 -->
  <script async type="text/javascript" src="/js/src/clipboard.min.js"></script>
  <script async type="text/javascript" src="/js/src/clipboard-use.js"></script>

  <!--share.js-->
  <link async rel="stylesheet" href="/sharejs/css/share.min.css">
  <script async src="/sharejs/js/social-share.min.js"></script>

  <!-- 模仿知乎卡片样式链接、崩溃欺骗特效 -->
  <script async type="text/javascript" src="/js/src/linkcard.js"></script>

  <!--崩溃欺骗 放在js文件最后-->
  <!--
  <script type="text/javascript" src="/js/src/crash_cheat.js"></script>
  -->

 
    <script src="https://myhkw.cn/api/player/164967637978" id="myhk" key="164967637978" m="1"></script>
 

<script async>window.onload=function(){var a=document.createElement('script'),b=document.getElementsByTagName('script')[0];a.type='text/javascript',a.async=!0,a.src='/sw-register.js?v='+Date.now(),b.parentNode.insertBefore(a,b)};</script></body></html>